<?php
$cnpjEdit = $_REQUEST["cnpjEdit"];
$nome;
$razaoSocial;
$telefone;
$fax;
$webSite;
$areaTotal;
$areaConstr;
$endCorresp;
$endFisc;
$Mensagem;//mensagem de exibição indicando se o end fisc eh o mesmo que o de corresp 
//endereço fisico
$rua;
$complemento;
$bairro;
$cidade;
$estado;
$pais;
$cep;
//endereco correspodencia;
$ruaCorres;
$complementoCorres;
$bairroCorres;
$cidadeCorres;
$estadoCorres;
$paisCorres;
$cep;
$conn = mysql_connect("localhost","root","");
if (!$conn)
{
   die('Erro de conexão Com o Banco de Dados: '. mysql_error());
}
mysql_selectdb("scae");
$remp = mysql_query("select * from empresa where CNPJ = ".$cnpjEdit);
while ($row = mysql_fetch_array($remp))
        {
            $nome        = $row["nome"];
            $razaoSocial = $row["razaoSocial"];
            $telefone    = $row["telefone"];
            $fax         = $row["fax"];
            $webSite     = $row["webSite"];
            $areaTotal   = $row["areaTotal"];
            $areaConstr  = $row["areaConstr"];
            $endCorresp  = $row["endCorres"];
            $endFisc     = $row["endFis"];
        }
$remp = mysql_query("select * from endereco where endId = ".$endFisc);
while ($row = mysql_fetch_array($remp))
{
    $rua = $row["rua"];
    $complemento= $row["complemento"];
    $bairro = $row["bairro"];        
    $cidade = $row["cidade"];
    $estado = $row["estado"];
    $pais   = $row["pais"];
    $cep    = $row["cep"];
        }        
if($endCorresp != $endFisc)
{
    $remp = mysql_query("select * from endereco where endId = ".$endCorresp);
    while ($row = mysql_fetch_array($remp))
        {
            $ruaCorres = $row["rua"];
            $complementoCorres= $row["complemento"];
            $bairroCorres = $row["bairro"];
            $cidadeCorres = $row["cidade"];
            $estadoCorres = $row["estado"];
            $paisCorres   = $row["pais"];
            $cepCorres    = $row["cep"];
        }
    
}
else
{
    $Mensagem = "Endereco fisico eh o mesmo para correspodencia";
}        
?>
<html>
  <link rel="stylesheet" type="text/css" href="estiloSCAE.css"/>
  <script type="text/javascript" src="editar.js"></script>
  <head>
    <title>Sistema de Cadastro e Acompanhamento de Empresas</title>
     <h1 align="center"><img  src="logo_suape.gif"></h1>

  </head>
  <body>
     <h2 align="center">Editar Empresa</h2>
     <form action="editEmp.php" method="post" name="form">
         <table align="center">
             <tr>
                  <td>
                      Nome da Empresa:
                  </td>
                  <td>
                      <input type="text" name="nome" value="<?php echo $nome; ?>" disabled>
                  </td>
              </tr>
              <tr>
                  <td>
                      CNPJ :
                  </td>
                  <td>
                      <input type="text" name="CNPJ" value="<?php echo $cnpjEdit; ?>" disabled>
                  </td>
              </tr>

              <tr>
                  <td>
                     Razao Social:
                  </td>
                  <td>
                      <input type="text" name="social" value="<?php echo $razaoSocial; ?>" disabled>
                  </td>
              </tr>
              <tr>
                  <td>
                      Telefone:
                  </td>
                  <td>
                      <input type="text" name="telefone" value="<?php echo $telefone; ?>" disabled>
                  </td>
              </tr>
              <tr>
                  <td>
                      FAX:
                  </td>
                  <td>
                      <input type="text" name="fax" value="<?php echo $fax; ?>" disabled>
                  </td>
              </tr>
              <tr>
                  <td>
                      Web Site:
                  </td>
                  <td>
                      <input type="text" name="website" value="<?php echo $webSite; ?>" disabled>
                  </td>
              </tr>
              <tr>
                  <td>
                      Area Total:
                  </td>
                  <td>
                      <input type="text" name="areatotal" value="<?php echo $areaTotal; ?>" disabled>
                  </td>
              </tr>
              <tr>
                  <td>
                      Area Construida :
                  </td>
                  <td>
                      <input type="text" name="areaconstr" value="<?php echo $areaConstr; ?>" disabled>
                  </td>
              </tr>
         </table>
         <h3 align="center" >Endereco Fisico da Empresa</h3>
        
      <table align="center">
          <tr>
                  <td>
                      Rua:
                  </td>
                  <td>
                      <input type="text" name="fisRua" value ="<?php echo $rua; ?>" disabled>
                  </td>
              </tr>
              <tr>
                  <td>
                      Complemento:
                  </td>
                  <td>
                      <input type="text" name="fisCompl" value ="<?php echo $complemento; ?>" disabled>
                  </td>
              </tr>
              <tr>
                  <td>
                      Bairro:
                  </td>
                  <td>
                      <input type="text" name="fisBairro" value ="<?php echo $bairro; ?>" disabled>
                  </td>
              </tr>
              <tr>
                  <td>
                     Cidade:
                  </td>
                  <td>
                      <input type="text" name="fisCidade" value ="<?php echo $cidade; ?>" disabled>
                  </td>
              </tr>
              <tr>
                  <td>
                      Estado:
                  </td>
                  <td>
                      <input type="text" name="fisEstado" value ="<?php echo $estado; ?>" disabled>
                  </td>
              </tr>
              <tr>
                  <td>
                      Pais:
                  </td>
                  <td>
                      <input type="text" name="fisPais" value ="<?php echo $pais; ?>" disabled>
                  </td>
              </tr>
              <tr>
                  <td>
                      CEP:
                  </td>
                  <td>
                      <input type="text" name="fisCep" value ="<?php echo $cep; ?>" disabled>
                  </td>
              </tr>
      </table>
      <?php
        if($endCorresp == $endFisc)
        {
           echo "<p align = center>".$Mensagem."</p>";
           echo "<input type= radio name= igual value = igual >";
        }
        else
        {
        ?>
        <h3 align="center" >Endereco para correspodencia da Empresa</h3>

       <table align="center">
          <tr>
                  <td>
                      Rua:
                  </td>
                  <td>
                      <input type="text" name="empRua" value ="<?php echo $ruaCorres; ?>" disabled>
                  </td>
              </tr>
              <tr>
                  <td>
                      Complemento:
                  </td>
                  <td>
                      <input type="text" name="empCompl" value ="<?php echo $complementoCorres; ?>" disabled>
                  </td>
              </tr>
              <tr>
                  <td>
                      Bairro:
                  </td>
                  <td>
                      <input type="text" name="empBairro" value ="<?php echo $bairroCorres; ?>" disabled>
                  </td>
              </tr>
              <tr>
                  <td>
                     Cidade:
                  </td>
                  <td>
                      <input type="text" name="empCidade" value ="<?php echo $cidadeCorres; ?>" disabled>
                  </td>
              </tr>
              <tr>
                  <td>
                      Estado:
                  </td>
                  <td>
                      <input type="text" name="empEstado" value ="<?php echo $estadoCorres; ?>" disabled>
                  </td>
              </tr>
              <tr>
                  <td>
                      Pais:
                  </td>
                  <td>
                      <input type="text" name="empPais" value ="<?php echo $paisCorres; ?>" disabled>
                  </td>
              </tr>
              <tr>
                  <td>
                      CEP:
                  </td>
                  <td>
                      <input type="text" name="empCep" value ="<?php echo $cepCorres; ?>" disabled>
                  </td>
              </tr>
      </table>
         <?php
        }
         ?>
        <table align="center">
            <tr>
                <td>
                    <input type="button" name="editar" value="Editar" onclick="Editar()">
                    </td>
                    <td>
                    <input type="submit" name="salvar" value="Salvar">
                </td>
            </tr>
        </table>
     </form>>
  </body>
</html>